package com.usermanage.SwaggerConfig;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Created by 過客 on 2018/8/8
 */
@Configuration
@EnableSwagger2
public class Swagger {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
//                .apis(RequestHandlerSelectors.basePackage("com.gm.ds.api"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("品宅用户构建api文档")
                    .description("品宅装饰科技有限公司用户模块api")
                .termsOfServiceUrl("http://www.cloud.pinza.com.cn/")
                .version("1.0")
//                .contact(new Contact("品宅装饰科技有限公司", "http://www.pinza.com.cn", ""))//设置文档的联系方式->1.2 Contact information
//                .licenseUrl("www.baidu.com")
                .build();
    }
    }
